﻿#ifndef __H_LABELVERIFICATION_H__
#define __H_LABELVERIFICATION_H__



#include <QLabel>


class CLabelVerification
	: public QLabel
{
	Q_OBJECT
public:
	CLabelVerification(QWidget* parent = 0, Qt::WindowFlags flags = 0);
	virtual ~CLabelVerification();
	// 获得验证码
	QString getVerificationCode();
protected:
	void init();

	virtual void mousePressEvent(QMouseEvent *event) final;
	virtual void paintEvent(QPaintEvent * event) final;
private:
	//这是一个用来生成验证码的函数
	void produceVerificationCode();
	//产生一个随机的字符
	QChar produceRandomLetter();
	//产生随机的颜色
	void produceRandomColor();

private:

	enum
	{
		NUMBER_FLAG,
		UPLETTER_FLAG,
		LOWLETTER_FLAG
	};

	//产生字符的数量
	const int m_letter_number = 4;
	//噪点的数量
	int m_noice_point_number;
	// 验证码
	QString m_strVerificationCode;
	// 颜色
	QColor* m_colorArray;

};


#endif // __H_LABELVERIFICATION_H__

